package com.xls.commonlibrary.util;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;

import com.orhanobut.logger.Logger;
import com.xls.commonlibrary.app.MainApplication;

public class ChannelUtil {


    public static String getChannel() {
        Context context = MainApplication.getAppContext();
        String channel = "";
        try {
            ApplicationInfo appInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
            if (appInfo != null && appInfo.metaData != null) {

//                 <meta-data
//                android:name="channel"
//                android:value="GooglePlay"/>

                channel = appInfo.metaData.getString("channel");// key必须一致
            }
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }


        Logger.d("============getChannel=============");
        Logger.d(channel);

        return channel;
    }
}
